<?php

class SeoInstall
{
	
	private $_config = array(
		'name' => 'seo',
		'title' => 'Seo module',
		'dependencies' => array(
		),
		'import' => array(
			'application.modules.seo.SeoModule',
			'application.modules.seo.models.SeoRouting',
			'application.modules.seo.models.SeoSettings',
		)
	);

	public function config()
	{
		return $this->_config;
	}
	
	public function install()
	{
		$sql = "DROP TABLE IF EXISTS {{seo_routing}};";
		Yii::app()->db->createCommand($sql)->execute();

		$sql="
	CREATE TABLE IF NOT EXISTS {{seo_routing}} (
	  `id` int(11) NOT NULL AUTO_INCREMENT,
	  `alias` text NOT NULL,
	  `url` text NOT NULL,
	  `language` varchar(2) NOT NULL,
	  PRIMARY KEY (`id`)
	) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
		Yii::app()->db->createCommand($sql)->execute();

		$sql = "DROP TABLE IF EXISTS {{seo_settings}};";
		Yii::app()->db->createCommand($sql)->execute();

		$sql="
	CREATE TABLE IF NOT EXISTS {{seo_settings}} (
	  `pageId` varchar(255) NOT NULL,
	  `description` text NOT NULL,
	  `keywords` text NOT NULL,
	  `defaultId` tinyint(1) NOT NULL DEFAULT '0',
	  PRIMARY KEY (`pageId`)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
		Yii::app()->db->createCommand($sql)->execute();

	}

	public function uninstall()
	{
		Yii::app()->db->createCommand()->dropTable('{{seo_routing}}');
	}
}